@import '../../styles/var.less';

.k-tree-select {
  display: inline-flex;
  min-width: 80px;
  box-sizing: border-box;
  vertical-align: middle;
  color: var(--kui-color-font);
  font-size: 14px;
  position: relative;
  outline: none;
  box-sizing: border-box;
  // flex-shrink: 0;
  align-items: center;
  background-color: var(--kui-color-back);
  border-radius: var(--kui-border-radius);
  border: 1px solid var(--kui-color-border);
  padding-left: 8px;
  transition: border .3s ease-in-out;
  line-height: 1.571;
  // max-width: 100%;
  &:hover {
    border-color: var(--kui-color-main);
    box-shadow: 0 0 0 2px var(--kui-color-main-90);
  }

  &-selection {

    box-sizing: border-box;
    outline: 0;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: pointer;
    position: relative;
    min-height: 30px;
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    height: 100%;
    box-sizing: border-box;
  }

  .k-tree-select-icon {
    font-size: 16px;
    color: var(--kui-color-icon);
    margin-right: 5px;
  }

  &-search-wrap {
    position: absolute;
    z-index: 1;
    background: none;
    overflow: hidden;
    max-width: 100%;

    .k-tree-select-search {
      border: none;
      width: 7px;
      min-width: 7px;
      height: 22px;
      padding: 0;
      background: none;
      outline: none;
      font-size: 14px;
      color: var(--kui-color-font);
    }
  }

  &-labels {
    transition: font-size .25s ease-in-out;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: 3px 0;

    .k-tree-select-tag {
      padding: 2px 22px 2px 5px;
      border: 1px solid var(--kui-color-border);
      background-color: var(--kui-color-border);
      border-radius: var(--kui-border-radius);
      display: inline-flex;
      align-items: center;
      font-size: 12px;
      position: relative;
      line-height: 18px;
      transition: all .25s ease-in-out;

      .k-icon {
        position: absolute;
        right: 3px;
        font-size: 16px;
        text-align: center;
        display: block;
        top: 50%;
        transform: translateY(-50%);

        &:hover {
          color: var(--kui-color-danger);
        }
      }
    }

    .k-tree-select-search-wrap {
      display: inline-block;
      position: relative;
      transform: none;
      left: 0;
      top: 0;
      margin: 0;
      vertical-align: middle;
    }
  }

  &-search-mirror {
    opacity: 0;
    white-space: pre;
    pointer-events: none;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    font-size: 12px;
  }

  &-placeholder {
    font-size: 14px;
    z-index: 0;
    line-height: 1.571;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--kui-color-disable-color);
    white-space: nowrap;
    max-width: 100%;
    box-sizing: border-box;
    transition: font-size .25s ease-in-out;
    line-height: 1;
  }

  &-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: none;
    background: transparent;
    box-sizing: border-box;
    width: 100%;
    line-height: 1.571;
    cursor: pointer;
    font-size: 14px;
    transition: font-size .25s ease-in-out;
  }

  &-arrow {
    font-size: 14px;
    box-sizing: border-box;
    transform: rotate(0deg);
    transform-origin: center;
    transition: transform .3s ease-in-out;
    transition: all .25s ease-in-out;
    color: var(--kui-color-icon);
    margin: 0 8px;

    #chevron-up {
      transform: rotate(180deg);
    }
  }

  &-clearable {
    display: none;
    font-size: 14px;
    color: var(--kui-color-icon);
    margin: 0 8px;

    &:hover {
      color: var(--kui-color-font);
    }
  }


  .k-tree-select-search-mirror,
  .k-tree-select-search {
    font-size: 14px;
    color: var(--kui-color-font);
  }



  &.k-tree-select-circle {
    border-radius: 30px;
  }
}

.k-tree-select-show-tags {
  padding-left: 4px;

  .k-tree-select-icon {
    margin-left: 4px;
  }
}

.k-tree-select-show-search {
  .k-tree-select-placeholder {
    position: absolute;
  }
}

.k-tree-select-multiple {
  .k-tree-select-placeholder {
    position: absolute;
  }
}


.k-tree-select-light {
  &.k-tree-select {
    border-color: transparent;
    background: var(--kui-color-gray-80);
    transition: none;
    box-shadow: none;

    &:focus,
    &:hover {
      box-shadow: none;
      border-color: transparent;
    }

    .k-tree-select-tag {
      background-color: var(--kui-color-gray-80);
      border-color: transparent;
    }
  }

  &:focus .k-tree-select {
    box-shadow: none;
    border-color: transparent;
  }
}



.k-tree-select-dropdown {
  user-select: none;
  border-radius: var(--kui-border-radius);
  width: inherit;
  max-height: 200px;
  overflow: auto;
  background-color: var(--kui-color-control-10);
  box-sizing: border-box;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .2);
  position: absolute;
  z-index: 1003;
  padding: 5px;
  box-sizing: border-box;
  border: 1px solid var(--kui-color-gray-80);

  ul {
    padding: 0;
    margin: 0;
    list-style: none;
    left: 0;
  }

  .k-tree-select-loading {
    padding: 10px;
    font-size: 14px;
    color: var(--kui-color-font);
    display: flex;
    align-items: center;

    .k-icon {
      font-size: 14px;
    }

    span {
      margin-left: 8px;
    }
  }

  .k-tree-select-item {
    margin: 0;
    line-height: 1;
    padding: 8px 8px;
    clear: both;
    color: var(--kui-color-font);
    font-size: 14px;
    white-space: nowrap;
    list-style: none;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    position: relative;
    border-radius: @radius;

    &:hover {
      background: var(--kui-color-hover);
    }

    &:active {
      background: var(--kui-color-active);
    }

    .k-icon {
      position: absolute;
      top: 0;
      right: 9px;
      font-size: 15px;
      top: 50%;
      transform: translateY(-50%);
      display: none;
      color: var(--kui-color-icon);
    }

    &:hover .k-icon,
    .k-icon {
      display: block;
    }
  }

  .k-tree-select-item-selected {
    background: var(--kui-color-selected);
    font-weight: 500;

    &:hover {
      background: var(--kui-color-selected);
    }

    .k-icon {
      color: var(--kui-color-main);
      display: block;
    }
  }

  .k-tree-select-item-disabled {
    background: var(--kui-color-disable-back);
    color: var(--kui-color-disable-color);
    cursor: not-allowed;
  }
}

.k-tree-select-dropdown-multiple {
  .k-tree-select-item {
    padding-right: 31px;
  }
}

.k-tree-select-dropdown-sm {
  .k-tree-select-item {
    font-size: 12px;
  }
}

.k-tree-select-sm {
  padding-left: 4px;

  .k-tree-select-icon {
    font-size: 14px;
    margin-right: 3px;
  }

  .k-tree-select-selection {
    min-height: 22px;
  }

  &.k-tree-select-show-tags {
    padding-left: 2px;

    .k-tree-select-icon {
      margin-left: 2px;
    }
  }

  .k-tree-select-arrow {
    font-size: 12px;
    margin: 0 4px;
  }

  .k-tree-select-clearable {
    margin: 0 4px;
    font-size: 12px;
  }

  .k-tree-select-label {
    line-height: 22px;
    height: 22px;
    padding-right: 23px;
    font-size: 12px;
  }

  .k-tree-select-placeholder {
    font-size: 12px;
  }

  .k-tree-select-search-wrap {
    .k-tree-select-search {
      height: 12px;
      font-size: 12px;
    }
  }

  .k-tree-select-labels {
    gap: 2px;
    margin: 2px 0;

    .k-tree-select-tag {
      padding: 2px 20px 2px 5px;
      line-height: 1;

      .k-icon {
        font-size: 14px;
      }
    }

    .k-tree-select-search-wrap {
      padding: 2px 0;

      .k-tree-select-search {
        font-size: 12px;
        height: 12px;
        line-height: 12px;
        left: 0;
        float: left;
      }
    }
  }

  .k-tree-select-search-mirror,
  .k-tree-select-search {
    font-size: 12px;
    color: var(--kui-color-font);
  }
}

.k-tree-select-lg {
  .k-tree-select-placeholder {
    font-size: 16px;
  }

  .k-tree-select-selection {
    font-size: 16px;
    min-height: 38px;
  }

  .k-tree-select-icon {
    font-size: 18px;
  }

  .k-tree-select-arrow {
    font-size: 18px;
  }

  .k-tree-select-clearable {
    font-size: 18px;
  }

  .k-tree-select-label {
    line-height: 38px;
    height: 38px;
    font-size: 16px;
  }

  .k-tree-select-search-wrap {
    .k-tree-select-search {
      height: 28px;
    }
  }

  .k-tree-select-labels {

    .k-tree-select-tag {
      padding: 7px 20px 7px 5px;
      font-size: 14px;
      line-height: 1;

      .k-icon {
        font-size: 16px;
      }
    }

    .k-tree-select-search-wrap {

      .k-tree-select-search {
        height: 28px;
        line-height: 28px;
        left: 0;
        float: left;
        font-size: 16px;
      }
    }
  }
}

.k-tree-select-open {
  border-color: var(--kui-color-main);
  box-shadow: 0 0 0 2px var(--kui-color-main-90);

  .k-tree-select-label {
    opacity: .5;
  }

  &.k-tree-select-light .k-tree-select-selection {
    box-shadow: none;
    border-color: transparent;
  }
}

.k-tree-select-disabled {
  color: var(--kui-color-disable-color);
  background: var(--kui-color-disable-back);

  .k-tree-select-label {
    cursor: not-allowed;
  }

  * {
    cursor: not-allowed;
  }

  .k-tree-select-arrow {
    color: var(--kui-color-disable-border);
  }

  &:hover,
  &:focus {
    border-color: var(--kui-color-disable-border);
    box-shadow: none;
  }
}

.k-tree-select-has-clear {
  &:hover {
    .k-tree-select-clearable {
      display: block;
    }

    .k-tree-select-arrow {
      display: none;
    }
  }
}

.k-tree-select-borderless {
  border-color: transparent;
  box-shadow: none;

  &:hover,
  &:focus {
    border-color: transparent;
    box-shadow: none;
  }

  .k-tree-select-selection {
    box-shadow: none;
    border-color: transparent;
    background-color: transparent;
  }
}


@keyframes drop-down {
  0% {
    opacity: 0;
    transform: scaleY(0)
  }

  to {
    opacity: 1;
    transform: scaleY(1)
  }
}

.k-tree-select-enter-active {
  transform-origin: 0 0;
  animation: drop-down .3s;
}

.k-tree-select-leave-active {
  transform-origin: 0 0;
  animation: drop-down .3s reverse
}